var global;

function Global(){
	this.object = new Array();
	this.dom = new Array();
}

Global.prototype.addElement = function(element, key){
	if(isString(element)) element = document.getElementById(element);
	
	if(!key){
		if(element.id) key = element.id;
		else return false;
	}
	
	this.dom[key.toUpperCase()] = element;
}

Global.prototype.getElement = function(key){
	return this.dom[key.toUpperCase()];
}

Global.prototype.createObject = function(key, obj){
	key = key.toUpperCase();
	
	if(obj) this.object[key] = obj;
	else this.object[key] = new Array();
}

Global.prototype.addObject = function(objKey, obj, key){
	this.addObjectItem(objKey, obj, key);
}

Global.prototype.addObjectItem = function(objKey, obj, key){
	if(!this.hasObject(objKey)) this.createObject(objKey);

	if(!key) key = obj.getKey();
	else{
		if(isNumeric(key)) key = objKey+'_'+key;
	}
	
	this.object[objKey.toUpperCase()][key.toUpperCase()] = obj;
}

Global.prototype.getObject = function(objKey, key){
	var obj = this.object[objKey.toUpperCase()];

	if(key) obj = obj[key.toUpperCase()];

	return obj;
}

Global.prototype.hasObject = function(objKey, key){
	objKey = objKey.toUpperCase();

	var obj = this.object;
	
	if(objKey in obj){
		if(key){
			key = key.toUpperCase();
			obj = this.object[objKey];

			if(key in obj) return true;
		}else return true; 
	}

	return false;
}